﻿<!DOCTYPE HTML>
<html>
<head>
    <title>AXNUT</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="Shell/assets/css/dpl-min.css" rel="stylesheet" type="text/css" />
    <link href="Shell/assets/css/bui-min.css" rel="stylesheet" type="text/css" />
    <link href="Shell/assets/css/main-min.css" rel="stylesheet" type="text/css" />
    
	<link rel="stylesheet" type="text/css" href="jquery-easyui-1.5.3/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="jquery-easyui-1.5.3/themes/icon.css">
	
</head>
<body>
<div class="header">
    <div class="dl-title">Welcome to AXNUT PlatForm</div>
    <div class="dl-log">
    	当前用户：<span id="LoginUserInfo" class="dl-log-user">即将显示当前登录的用户</span>
		<a id="modPassword" href="#" title="更改密码" class="dl-log-quit">[更改密码]</a>
		<a id="logout" href="#" title="退出系统" class="dl-log-quit">[退出系统]</a>
    </div>
</div>
<div class="content">
    <div class="dl-main-nav">
        <div class="dl-inform">
        	<div class="dl-inform-title">
        		<s class="dl-inform-icon dl-up"></s>
        	</div>
       	</div>
        <ul id="J_Nav"  class="nav-list ks-clear">
            <li class="nav-item dl-selected">
            	<div class="nav-item-inner nav-home">菜单加载中</div>
            </li>
			<li class="nav-item dl-selected">
				<div class="nav-item-inner nav-order">菜单加载ing</div>
			</li>
        </ul>
    </div>
    <ul id="J_NavContent" class="dl-tab-conten">

    </ul>
</div>
<script type="text/javascript" src="Shell/assets/js/jquery-1.8.1.min.js"></script>

<script type="text/javascript" src="Shell/assets/js/bui-min.js"></script>
<script type="text/javascript" src="Shell/assets/js/common/main-min.js"></script>
<script type="text/javascript" src="Shell/assets/js/config-min.js"></script>   

<script type="text/javascript" src="jquery-easyui-1.5.3/jquery.easyui.min.js"></script> 
<script>
	$(function(){
    	var res1 = $.ajax({url:"./auth/getLoginUser",async:false});
    	var res2 = $.ajax({url:"./auth/getLoginRole",async:false});   
    	var res3 = eval("(" + res1.responseText + ")");
    	var res4 = eval("(" + res2.responseText + ")"); 	  
    	var loginUserName = res3.login_user.name_cn;
    	var loginRoleName = res4.login_role.role_name;
    	$(".dl-log-user").html(loginUserName + "|" + loginRoleName);
    	//修改密码按钮的响应事件
        $("#modPassword").click(function() {
        	$.messager.prompt('修改密码', '请输入您当前的系统密码：', function(r){				
        		if (r){
        			var checkres = $.ajax({url:"./auth/checkLoginUserPassword?password="+r,async:false});
        			if (checkres.responseText=="true"){
						$.messager.prompt('修改密码', '请输入您的新密码：', function(newpwd){
							if (newpwd){
								var modres = $.ajax({url:"./auth/Login.let?action=checkLoginUserPassword&password="+newpwd,async:false});
								if ("yes"==modres.responseText){
									$.messager.alert("操作提示", "密码修改成功！","info");
								} else {
									$.messager.alert("操作提示", "密码修改失败！","error");
								}
							}
						});	
					} else {
						alert("O"+checkres.responseText+"O");
						$.messager.alert("操作提示", "密码输入错误！","error");
					}
				}
			});
        });
        //退出系统按钮的响应事件
        $("#logout").click(function() {
        	$.messager.confirm('退出系统', '您确定要退出本次登录吗?', function(r){
				if (r){
					location.href = './authlogin/logout';
				}
            });
        });
	})

    BUI.use('common/main',function(){
    	
    	//构建页面上方的系统标签 begin
    	var obj = $.ajax({url:"./auth/getLoginUserFunctionTree",async:false});
    	var res = eval("(" + obj.responseText + ")");
    	var functionTree =  res.function_tree.root;
    	var projectTag = '';
    	for (var i in functionTree.children)
    	{
    		projectTag = projectTag + '<li class="nav-item dl-selected">';
    		projectTag = projectTag + '<div class="nav-item-inner nav-home">';
    		projectTag = projectTag + functionTree.children[i].object.function_name;
    		projectTag = projectTag + '</div>';
    		projectTag = projectTag + '</li>';
    	}
    	$("#J_Nav").html(projectTag);
    	//构建页面上方的系统标签 end 
    	
     	//构建菜单树(递归方式) begin
     	function createMenuTree(node){
     		var menuTree= {};
    		if (node.level=='1'){
    			menuTree.menu = [];
    			for (var i in node.children){
    				menuTree.menu.push( createMenuTree(node.children[i]));
    			}
    		} else if (node.level=='2') {
    			menuTree.id = node.object.function_id;
    			menuTree.menu = [];
    			for (var i in node.children){
    				menuTree.menu.push( createMenuTree(node.children[i]));
    			}
    		} else if (node.level=='3') {
    			menuTree.text = node.object.function_name;
    			menuTree.items = [];
    			for (var i in node.children){
    				menuTree.items.push( createMenuTree(node.children[i]));
    			}
    		} else if (node.level=='4') {
    			menuTree.id = node.object.function_id;
    			menuTree.text = node.object.function_name;
    			if (node.object.function_url!=null){
        			if (node.object.function_url.indexOf("?")>0) {
        				menuTree.href  = node.object.function_url  + "&theme=bootstrap";
        			} else{
        				menuTree.href  = node.object.function_url  + "?theme=bootstrap";
        			}    		
    			}	
    		}
     		return menuTree;
     	}
     	//构建菜单树(递归方式)  END
     	
     	var menuTree = createMenuTree(functionTree); 
        new PageUtil.MainPage({
            modulesConfig : menuTree.menu
        });
    });
</script>
<div style="text-align:center;">
<p>本系统由古宏健开发！未经允许禁止使用！</p>
</div>
</body>
</html>